<?php
/**
 * @package    com.promobico.mcm
 * @subpackage mvm
 * @link promobico.com
 * @license  All rights reserved.
 */
 
// no direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');
 
/**
 * HTML View class for the MvmView Component
 *
 * @package    mvm
 */
 
class MvmViewMvm extends JView
{
    function display($tpl = null)
    {
		// Get the output format (xml, html, feed etc...)
		$document	= JFactory::getDocument();
		$vFormat = $document->getType();
		
		
		/* Set the layout */
//		$view->setLayout(JRequest::getVar('layout','default'));
		$vendorId = JRequest::getInt('vendorid', 1);
		
		$categoryModel = $this->getModel('category');
		$productModel = $this->getModel('product');

	    $categoryId = JRequest::getInt('category_id', 0);
        $categoryChildren = $categoryModel->getChildCategoryList($vendorId, $categoryId);

        $this->assignRef('categories',	$categoryChildren);

       // if(!class_exists('calculationHelper')) require(JPATH_SITE.DS.'components'.DS.'com_mvm'.DS.'helpers'.DS.'calculationh.php');
       JLoader::import('helpers.calculationh', JPATH_COMPONENT);


//        if (VmConfig::get('showFeatured', 1)) {
			$featuredProducts = & $productModel->getGroupProducts('featured', $vendorId, '', 15);
			$this->assignRef('featuredProducts', $featuredProducts);
//		}

//		if (VmConfig::get('showlatest', 1)) {
			$latestProducts = & $productModel->getGroupProducts('latest', $vendorId, '', 15);
			$this->assignRef('latestProducts', $latestProducts);
//		}

//        if (VmConfig::get('showTopten', 1)) {
			$toptenProducts = & $productModel->getGroupProducts('topten', $vendorId, '', 15);
			$this->assignRef('toptenProducts', $toptenProducts);
//		}

		JLoader::import("helpers.permissions", JPATH_COMPONENT);
		$showBasePrice = Permissions::getInstance()->check('admin'); //todo add config settings
		$this->assignRef('showBasePrice', $showBasePrice);

	    JLoader::import('helpers.mvmuri',JPATH_COMPONENT);

        parent::display($tpl);
    }
}